<?php
/**
 * Created by PhpStorm.
 * User: zzw
 * Date: 17-2-28
 * Time: 下午2:03
 */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Needs_model extends MY_Model {

    protected $table = 'needs';
    public function set($id, $arr) {
        $this->db->set($arr[0],$arr[1],false)
            ->where(array('id' => $id))
            ->update($this->table);
        return $this->db->affected_rows();
    }

    /**
     * (仲裁)
     */
    public function get_status_nums(){
        $query = $this->db
            ->select('count(*) as total')
            ->from($this->table)
            ->where('arbitrate',1)
            ->or_where('c_arbitrate',1)
            ->get();
        return $query->row_array();
    }

    /**
     * 未进行处理的数量（有人认领结束后超过24小时没有指派的数量）
     */
    public function get_status_nums2(){
        $time = time()-24*3600;
        $query = $this->db
            ->select('count(*) as total')
            ->from($this->table)
            ->where(array('claim_status'=>2,'updated <'=>$time))
            ->get();
        return $query->row_array();
    }
}